/**
*MainNavView Page class
*auth:lww
*version:1.0
*since:2014-10-11
*@param:context:Application
*@param:router:Router
*/
function MainNavView(context,router) {
    this.id = "";
    this.name = "MainNavView";
    this.version = "1.0.0";
    this.mContext = context;
    this.mRouter = router;   
    this.mRootViewObject = null;    
    this.mHeight = 40;  
    this.leftLayer = null; 
    this.rightLayer = null; 
    this.leftWidth = 180;   
    this.mainNav = null;   
    this.mTabMenuView = null;
}
MainNavView.prototype.getId = function () {
    if (this.id == null || this.id == "") {
        this.id = id();
    }
    return this.id;
};
MainNavView.prototype.setId = function (ids) {
    this.id = ids;
};
MainNavView.prototype.view = function () {
    return this.invalidate();
};
MainNavView.prototype.invalidate = function () {    
    if (this.mRootViewObject == null) {
        this.mRootViewObject = new LinearLayout(this.mContext);
        this.mRootViewObject.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
        this.mRootViewObject.setBackground(new Drawable("#ffffff", null));
        this.mRootViewObject.view().style.minWidth = "200px";        
        this.mRootViewObject.view().style.overflow = "hidden";
        this.initView();
    }
    return this.mRootViewObject.view();
};
MainNavView.prototype.initView = function () {
    //container layer
    var containerLayer = new LinearLayout(this.mContext);  
    containerLayer.setLayoutParams(new LayoutParams(MATCH_PARENT, this.mHeight));
    this.leftLayer = new LinearLayout(this.mContext); 
    this.rightLayer = new LinearLayout(this.mContext); 
    this.setViewStyle();   
    //add to container    
    containerLayer.addChildView(this.leftLayer.view());
    containerLayer.addChildView(this.rightLayer.view());   
    this.mRootViewObject.addChildView(containerLayer.view());
    this.mRootViewObject.addChildView(setCss($c("div"), "bline"));
};
MainNavView.prototype.setViewStyle = function () {
    var lparms = new LayoutParams(this.leftWidth, this.mHeight); 
    var rparms = new LayoutParams(MATCH_PARENT, this.mHeight);
    rparms.mLeftMargin = this.leftWidth;
    this.leftLayer.setLayoutParams(lparms);    
    setCssFloat(this.leftLayer.view(), "left");
    this.rightLayer.setLayoutParams(rparms);
};
MainNavView.prototype.updateMainNavView = function(){
    this.initMainLogoView();
    this.initMainNavView();
    this.initNavUserInfo();
};
MainNavView.prototype.initMainLogoView = function(){    
    var logoView = formatHtmlIco("./stylesheets/logo/logo_title.jpg","170px","40px","","logo");
    this.leftLayer.setView(logoView);
};
MainNavView.prototype.initMainNavView = function(){
    this.mainNav = setCss($c("div"), "mainNav");    
    this.mTabMenuView = this.mRouter.initMainMenuView("tabMenuView","tabItem");  
    setChild(this.mainNav, this.mTabMenuView.view());   
    this.rightLayer.setView(this.mainNav);
    this.mTabMenuView.setSelected(0);
};
MainNavView.prototype.initNavUserInfo = function(){
    var navUserInfo = setCss($c("div"), "navUserInfo"); 
    var loginInfo = formatHtmlString("welcome: "+this.mRouter.authInfo.getUserName(),"#71a4d4", "12px", "bold", "5px 0 0 2px");   
    var exitInfo = createLinkBtn(formatHtmlString("登出","#71a4d4", "12px", "bold", "5px 0 0 0px"), function(router){ router.logout();}, this.mRouter, "linkBtn");
    var aboutUrl = this.mContext.mAppConfig.getAboutPageUrl();
    var aboutInfo = createLinkBtn(formatHtmlString("关于","#71a4d4", "12px", "bold", "5px 0 0 0px"), function(router){      
        router.openDialogPage("关于", aboutUrl, 400, 200, "./stylesheets/ico/info.png");
    }, this.mRouter, "linkBtn");
    setChild(navUserInfo, loginInfo);
    appendChild(navUserInfo, formatHtmlString("|","#71a4d4", "12px", "bold", "5px 0 0 2px"));
    appendChild(navUserInfo, exitInfo); 
    appendChild(navUserInfo, formatHtmlString("|","#71a4d4", "12px", "bold", "5px 0 0 2px"));
    appendChild(navUserInfo, aboutInfo); 
    this.rightLayer.addChildView(navUserInfo);    
};

markscript("MainNavView");
//end MainNavView.js